class User < ActiveRecord::Base
  belongs_to :company
  has_one :company_created, :class_name => "Company"
  has_many :tasks
  has_many :tasks_owned, :class_name => "Task"
  has_many :projects

  def self.add(account_type, email, name, twitter_user_id)
    user = User.find_by_twitter_user_id(twitter_user_id)
    puts user.nil?
    if user.nil?
      User.create do |u|
        u.account_type = account_type
        u.email = email
        u.name = name
        u.twitter_user_id = twitter_user_id
        u.status = ACCOUNT_STATUS_ACTIVE
        u.save!
      end
    end
  end
end
